//
//  ChoseOneCell.m
//  条件选择
//
//  Created by Michael Li on 2018/7/16.
//  Copyright © 2018年 Michael Li. All rights reserved.
//

#import "ChoseOneCell.h"
#import "UIView+ZF.h"
@interface ChoseOneCell()

@end
#define kUIScreen [UIScreen mainScreen].bounds
@implementation ChoseOneCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

+ (instancetype)cellWithTableView:(UITableView *)tableView
{
    static NSString *cellId = @"ListCell";
    ChoseOneCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
    if (cell == nil) {
        //        cell = [[ListCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:cellId];
        cell = [[ChoseOneCell alloc]initWithFrame:kUIScreen];
    }
    return cell;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self setupSubViews];
    }
    return self;
}

- (void)setupSubViews
{
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    [self.contentView addSubview:self.imgView];
    [self.contentView addSubview:self.titleLabel];
}

- (void)setTitle:(NSString *)title
{
    _title = title;
    _titleLabel.text = title;
    
}

- (void)setIsSelected:(BOOL)isSelected
{
    if (isSelected) {
        [self setSelected:YES animated:YES];
    }else {
        [self setSelected:NO animated:YES];
    }
}

- (UILabel *)titleLabel
{
    if (!_titleLabel) {
        _titleLabel = [[UILabel alloc] init];
        CGFloat titleLabelH = self.h - 2*10.f;
        _titleLabel.frame = CGRectMake(16, 10.f, self.w - 100.f, titleLabelH);
        _titleLabel.font = [UIFont systemFontOfSize:14.f];
        //[UIColor colorWithRed:102/255.0 green:102/255.0 blue:102/255.0 alpha:1]
        _titleLabel.textColor = [UIColor colorWithRed:102/255.0 green:102/255.0 blue:102/255.0 alpha:1];
    }
    return _titleLabel;
}

- (UIImageView *)imgView
{
    if (!_imgView) {
        _imgView = [[UIImageView alloc] init];
        //        CGFloat imgViewWH = self.h - 2*10.f;
        _imgView.contentMode = UIViewContentModeCenter;
        _imgView.frame = CGRectMake(kUIScreen.size.width-12-16, (self.h-9)/2, 12, 9);
        //        _imgView.image = [UIImage imageNamed:@"ic_news_selected"];
    }
    return _imgView;
}

@end
